#include <iostream>
#include <vector>

using namespace std;

// https://leetcode.cn/problems/largest-color-value-in-a-directed-graph/?envType=daily-question&envId=2025-05-26
// 1857.

class Solution {
public:
    string dfs(vector<vector<int>> &graph, vector<string> &recordColorOfNode, vector<int> & recordStatus, string color, int curIndex){
        recordStatus[curIndex] = 1;
        string preStr;
        for (int i : graph[curIndex])
        {
            if(recordStatus[i] == 1 || recordStatus[i] == 0 && (preStr = (graph, recordColorOfNode, recordStatus, color, i)) == "EOF"){
                return "EOF";
            }
        }
        if(preStr.find(color[curIndex]) == std::string::npos){
            preStr.push_back(color[curIndex]);
        }
        recordStatus[curIndex] = 2;
        return preStr;
    }
    int largestPathValue(string colors, vector<vector<int>>& edges) {
        // 构建图
        vector<vector<int>> graph(colors.size());
        for(auto it : edges){
            graph[it[0]].push_back(it[1]);
        }
        // 记录每个节点的颜色
        vector<string> recordColorOfNode(colors.size());
        vector<int> recordStatus(colors.size());
        for (int i = 0; i < colors.size(); i++){
            if(recordStatus[i] == 0){
                if(dfs(graph,recordColorOfNode, recordStatus, colors, i) == "EOF"){
                    return -1;
                }
            }
        }
    }
};

int main()
{
    return 0;
}